package com.mxpio.erp.quality.controller;

import com.mxpio.erp.common.quality.entity.VEUnqualifiedDisposal;
import com.mxpio.erp.common.quality.entity.VEUnqualifiedProduct;
import com.mxpio.erp.common.quality.service.VEUnqualifiedDisposalService;
import com.mxpio.erp.common.quality.service.VEUnqualifiedProductService;
import com.mxpioframework.common.vo.Result;
import com.mxpioframework.jpa.query.Criteria;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.UnsupportedEncodingException;

@Tag(name = "VEUnqualifiedProductController", description = "不合格品查询报表")
@RestController
@RequestMapping("/erp/quality/product/")
public class VEUnqualifiedProductController {
    @Autowired
    private VEUnqualifiedProductService veUnqualifiedProductService;
    @GetMapping("unqualified/page")
    @Operation(summary = "不合格品报表-分页 ", description = "不合格品报表-分页 ", method = "GET")
    public Result<Page<VEUnqualifiedProduct>> getUnqualifiedDisposal(Criteria criteria, Integer pageSize, Integer pageNo) throws UnsupportedEncodingException {
        Pageable pageAble = PageRequest.of(pageNo-1, pageSize);
        Page<VEUnqualifiedProduct> page = veUnqualifiedProductService.listPage(pageAble, criteria);
        return Result.OK(page);
    }
}
